package cn.tedu.oop;

/**
 * @Author 金帮嘉诚
 * @Date 2021-06-08 周二 19:51
 */
/*本类用于this关键字测试2*/
    /*this还可以实现构造方法间的调用，注意  禁止递归调用*///Recursive constructor invocation
    /*注意   this（）实现构造方法的调用时 必须放在构造方法的第一行*///Call to 'this()' must be first statement in constructor body
public class TestVariableThis2 {
    public static void main(String[] args) {
        Dog dog1=new Dog();
        Dog dag2=new Dog("?????????????");
    }
}
class Dog{
    String name;

    public Dog() {
        //this("haaaaaaaaaaaaaaaaaaaaaa");
        System.out.println("无参");
        System.out.println("this.name = " + this.name);
    }

    public Dog(String name) {
        this();
        System.out.println("有参");
        this.name = name;
        System.out.println("this.name = " + this.name);
    }
}

